
#!/usr/bin/env python
#coding=utf-8

#阿里云短信服务
'''
AccessKey ID     :      LTAI4G2UtVnkYCt62EC8e7V1
AccessKey Secret :      CWphiusFhERZZXOgJWVnRyTrm7t9PZ
'''

from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest
client = AcsClient('LTAI4G2UtVnkYCt62EC8e7V1', 'CWphiusFhERZZXOgJWVnRyTrm7t9PZ', 'cn-hangzhou')

request = CommonRequest()
request.set_accept_format('json')
request.set_domain('dysmsapi.aliyuncs.com')
request.set_method('POST')
request.set_protocol_type('https') # https | http
request.set_version('2017-05-25')
request.set_action_name('SendSms')

request.add_query_param('RegionId', "cn-hangzhou")
request.add_query_param('PhoneNumbers', "15021625324")
request.add_query_param('SignName', "[测试专用]阿里云通信")                   #短信签名
request.add_query_param('TemplateCode', "SMS_190275132")        #短信模板
request.add_query_param('TemplateParam', {"code": "123456"})    # 验证码
request.add_query_param('SmsUpExtendCode', "1")                 # 外部流水扩展字段

response = client.do_action(request)
# python2:  print(response)
print(str(response, encoding = 'utf-8'))